<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ taglib prefix="j" uri="http://www.jqb.com/jstl/jsplabtags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LISTTAG</title>
<script type="text/javascript" language="javascript">
	window.onload = function() {
		document.getElementById("form").onsubmit = function() {
			var form = document.getElementById("form");
			var iderrormsg = document.getElementById("iderrormsg");
			var interests = document.getElementsByName("interest");
			var regex = /^\S+$/;
			var emailregex = /^\w+_*\w*@\w+\.com$/;
			var nickname = form.idnickname.value;
			var email = form.idemail.value;

			if (!regex.test(nickname)) {
				iderrormsg.textContent = "nickname?";
				return false;
			}
			if (!emailregex.test(email)) {
				iderrormsg.textContent = "email?";
				return false;
			}
			var count = 0;
			for ( var i = 0; i < interests.length; i++) {
				if (!interests[i].checked) {
					count++;
				}
			}
			if (count == 3) {
				iderrormsg.textContent = "interest?";
				return false;
			}
			return true;

		};
	};
</script>
</head>
<body>
	<jsp:include page="/jspdemo/header.jsp" />

	<form id="form" action="/test/infoOperateServlet?infooperate=listtag" method="post">
		昵称:<input id="idnickname" type="text" name="nickname"><br>
		邮箱:<input id="idemail" type="text" name="email"><br> 
		兴趣:<input type="checkbox" name="interest" value="旅游">
		旅游 <input type="checkbox" name="interest" value="上网">
		上网 <input type="checkbox" name="interest" value="看书"><br> 
		看书<input type="reset" value="reset"><input type="submit" value="submit">
	</form>
	<j:list id="t" name="list" scope="request">
		${t}<br>
	</j:list>
	<br>
	<label id="iderrormsg"></label>
</body>
</html>